package org.zhongyin.Dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

import org.zhongyin.JPA.Entity.OBJECTS;

public class GREEDODaoImpl implements IGREEDODao{

	private static final String PERSISTENCE_UNIT_NAME = "GREEDO";
	private static EntityManagerFactory factory;
	private EntityManager em;
	
	
	public GREEDODaoImpl(){
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		em = factory.createEntityManager();
	}
	
	@Override
	public OBJECTS getPK(){
		Query query = em.createNamedQuery("getPK");
		OBJECTS result = (OBJECTS) query.getSingleResult();
		return result;
	}
	
	
	
	public static void main(String[] args) {
		GREEDODaoImpl greedo = new GREEDODaoImpl();
		System.out.println(greedo.getPK().getId().getObjIdTop());
		System.out.println(greedo.getPK().getId().getObjIdMiddle());
		System.out.println(greedo.getPK().getId().getObjIdBottom());

	}

}
